<template>
	<view class="shopHomepage">
		<cu-custom :isBack="true" textWeight="600" textSize="16" fhColor="#000" textColor="#333">
			<block slot="content">商铺主页</block>
		</cu-custom>

		<view class="shopPage">
			<view class="left">
				<view class="profile">
					<image :src="ShopDetailsData.shopLogo" class="img"></image>
				</view>
				<text>{{ ShopDetailsData.shopName }}</text>
			</view>
			<view class="right"></view>
		</view>

		<view class="titleBox">基本信息</view>

		<view class="details">
			<view class="table">
				<view class="left">联系人</view>
				<view class="right">{{ ShopDetailsData.contacts ? ShopDetailsData.contacts : '-' }}</view>
			</view>
			<view class="table" v-if="ShopDetailsData.contactsPhone">
				<view class="left">联系电话</view>
				<view class="right">
					<view class="text">{{ ShopDetailsData.contactsPhone ? ShopDetailsData.contactsPhone : '无' }}</view>
					<image class="img" :src="imgUrl + 'phone.png'" mode="heightFix" @click="openPhone"></image>
				</view>
			</view>
			<view class="table">
				<view class="left">所在地区</view>
				<view class="right">{{ ShopDetailsData.addrProvinceName + ShopDetailsData.addrCityName }}
				</view>
			</view>
			<view class="table">
				<view class="left">店铺地址</view>
				<view class="right">
					<view class="text">{{ ShopDetailsData.address ? ShopDetailsData.address : '无' }}</view>
					<image class="img" :src="imgUrl + 'locations.png'" mode="heightFix"
						@click="openCity(ShopDetailsData)"></image>
				</view>
			</view>
			<view class="table">
				<view class="left">营业时间</view>
				<view class="right">{{ ShopDetailsData.openTime ? ShopDetailsData.openTime : '-' }}</view>
			</view>
			<view class="table">
				<view class="left">其他</view>
				<view class="right">{{ ShopDetailsData.remark ? ShopDetailsData.remark : '无' }}</view>
			</view>
			<view class="phote" v-if="ShopDetailsData.shopImages&&ShopDetailsData.shopImages.length!==0">
				<view class="left">店内照片</view>
				<view class="imgbox">
					<!-- <view class="imgs" v-for="i in phote" :key="i" :style="{width:phote.length-3>=0?100/3+'%':100/phote.length+'%'}"> -->
					<view class="imgs" v-for="(item,index) in ShopDetailsData.shopImages" :key="index"
						@click="seeImg(ShopDetailsData.shopImages,index)">
						<image :src="item" class="shopImages"></image>
					</view>
				</view>
			</view>
		</view>

		<view class="bg"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgUrl: this.$http.imgUrl + "/static/commercial/",
				phote: 9,
				ShopId: "",
				ShopDetailsData: {},
			};
		},
		onLoad(options) {
			this.ShopId = options.id;
			this.initCsh();
		},
		methods: {
			// 拨打电话
			openPhone() {
				uni.makePhoneCall({
					phoneNumber: this.ShopDetailsData.contactsPhone //仅为示例
				})
			},

			// 打开地图
			openCity(item) {
				uni.openLocation({ //​使用微信内置地图查看位置。
					latitude: Number(item.lat), //要去的纬度-地址
					longitude: Number(item.lng), //要去的经度-地址
					address: item.address, //要去的详细地址
				})
			},

			// 查看图片
			seeImg(imgList, index) {
				var arr = []
				for (var i in imgList) {
					arr.push(imgList[i])
				}
				uni.previewImage({
					urls: arr,
					current: index
				})
			},

			initCsh() {
				this.getShopDetails();
			},
			async getShopDetails() {
				const url = this.api.new_shop.shopDetails;
				const res = await this.https.get(url, {
					id: this.ShopId,
				});
				res.shopImages = JSON.parse(res.shopImages);
				// console.log(res, '商铺详情')
				this.ShopDetailsData = res;
			},
		},
	};
</script>

<style lang="scss" scoped>
	.shopHomepage {
		background: url(https://lzmordershop.oss-cn-hangzhou.aliyuncs.com/static/bac.png) no-repeat;
		background-size: 100%, 100%;
		height: 100vh;
		padding: 0 24rpx;

		// background-position:top 0 right 0,bottom 0 right 0;
		.shopPage {
			margin-top: 24rpx;
			padding: 0 24rpx;
			width: 702rpx;
			height: 168rpx;
			background: #ffffff;
			box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(153, 153, 153, 0.12);
			border-radius: 24rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.left {
				display: flex;
				align-items: center;
				font-weight: 600;
				color: #333333;
				font-size: 28rpx;

				.profile {
					margin-right: 16rpx;
					width: 120rpx;
					height: 120rpx;
					text-align: center;
					line-height: 120rpx;

					.img {
						width: 100%;
						height: 100%;
						color: #3559a0;
					}
				}
			}

			.right {
				width: 152rpx;
				height: 124rpx;
				background: url(https://lzmordershop.oss-cn-hangzhou.aliyuncs.com/static/commercial/bg1.png) no-repeat;
				background-size: 100%;
			}
		}

		.titleBox {
			width: 112rpx;
			height: 28rpx;
			font-size: 28rpx;
			font-weight: 400;
			color: #333333;
			line-height: 28rpx;
			margin-top: 32rpx;
		}

		.details {
			position: relative;
			z-index: 1;
			margin-top: 16rpx;
			width: 702rpx;
			// height: 760rpx;
			background: #ffffff;
			box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(153, 153, 153, 0.12);
			border-radius: 24rpx;
			padding: 32rpx 24rpx;

			.phote {
				// height: 312rpx;
				width: 100%;
				display: flex;

				.left {
					width: 150rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: #999999;
				}

				.imgbox {
					flex: 1;
					display: flex;
					flex-wrap: wrap;

					.imgs {
						height: 144rpx;
						width: 33.333333%;
						margin-bottom: 24rpx;

						.shopImages {
							width: 144rpx;
							height: 144rpx;
						}

						&:nth-child(3n) {
							padding-right: 0;
						}
					}

					// .imgs:nth-child(3n){
					// 	width: 144rpx;
					// 	padding-right: 0;
					// }
				}
			}

			.table {
				width: 100%;
				margin-bottom: 40rpx;
				display: flex;
				align-items: start;

				.left {
					width: 150rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: #999999;
					height: 100%;
					display: flex;
					align-items: start;
					//margin-right: 80rpx;
				}

				.right {
					// width: 476rpx;
					flex: 1;
					display: flex;
					justify-content: space-between;
					font-size: 24rpx;
					font-weight: 500;
					color: #333333;

					.img {
						width: 28rpx;
						height: 28rpx;
					}

					.text {
						max-width: 454rpx;
						align-items: center;
						// margin-right: 10rpx;
					}
				}

				&:last-child {
					margin-bottom: 0;
				}
			}
		}

		.bg {
			z-index: -1;
			width: 750rpx;
			height: 237rpx;
			position: fixed;
			bottom: 0;
			left: 0;
			background: url(https://lzmordershop.oss-cn-hangzhou.aliyuncs.com/static/commercial/bg4.png) no-repeat;
			background-size: 100%;
			// background-color: #333333;
			z-index: 0;
		}
	}
</style>